home *** CD-ROM | disk | FTP | other *** search
/ Alles Voor Internet / Tout Pour Internet / alles voor internet.iso / MacInternet™ / Net / Utilities / Seer family 2.0 / seer_common / sc_text_pak.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-08-29  |  2.6 KB  |  89 lines  |  [TEXT/KAHL]

  1. /*
  2.     sc_text_pak.c - convert a packet to ascii text
  3. */
  4. #include "sc.h"
  5. #include "sc_seer_globals.h"
  6. #include "pdl_data.h"
  7. #include "OUT.h"
  8.  
  9. void flush_out()
  10. {int bufsize;
  11.  /*draw the current line,then advance the display down one line*/
  12. /***********************************************************
  13.  orginaly out_break was used to cause line breaks to only happen
  14.  on full fields.  This doesn't looks worse than having breaks on
  15.  each string, so that is why the check for out_break is ifdefed out here.
  16. */
  17. #ifdef BREAK_ON_FIELDS
  18.  if(out_break==NIL)        /*if no break point on this line, */
  19. #endif
  20.      out_break=out_pt;    /*print whatever is here*/
  21.  bufsize=out_break-out_start;
  22.  (*out_flush)(out_start,bufsize); /* print this text*/
  23.  /*bufsize=number of chars left in buffer after line break*/
  24.  bufsize=out_pt-out_break;
  25.  *out_start =  ' ';        /*indent lines after the first one one space*/
  26.  BlockMove(out_break,out_start+1,(long)bufsize);    /*move chars to buffer start*/
  27.  out_pt=out_start+bufsize+1;        /*set out_pt for remaining characters*/
  28.  out_break=NIL;            /*don't know where to break yet*/
  29. }
  30.  
  31. /*
  32.     print this string
  33. */
  34. void OUT_str(str)
  35. register char *str;
  36. {register int slen;
  37.  slen=strlen(str);            /*see how many characters long the string is*/
  38.  if(((out_stop-out_pt)-slen) < 0)    /*would this string overflow the buffer?*/
  39.      flush_out();            /*yes, so free up some space*/
  40.  BlockMove(str,out_pt,(long)slen); /*add on the current string*/
  41.  out_pt += slen;            /*advance string pointer over added characters*/
  42. }
  43.  
  44. /*the current position is ok to break lines at*/
  45. void OUT_brk()
  46. {if(out_start!=out_pt)
  47.    *out_pt++ =',';        /* put out the seperator*/
  48.  out_break = out_pt;
  49. }    
  50.  
  51. /*
  52.     print the requested packet onto the current output stream.
  53.     This works for printing to files and to the screen.
  54. */
  55. int text_pak(a_pak)
  56. uint32 a_pak;
  57. {SR_record gparg;
  58.  int itemp;
  59.  
  60.  /*retrieve the desired packet from the seer queue*/
  61.  gparg.x.a_getpak.pak_num=a_pak;
  62.      
  63.  itemp=seer_ctl(SRc_getpak,&gparg);    /*read the packet*/
  64.  if(itemp==SRe_notyet)    /*packet not here yet?*/
  65.      return true;            /*not here, say so*/
  66.  if(itemp!=SRe_noErr)    /*got the packet?*/
  67.      bomb(BOMB_sr_getpak,BMB_no_os,BMB_no_special); /*no die*/
  68.  
  69.  out_pt=out_start;
  70.  out_break=NIL;
  71.  
  72.  /*print the header*/
  73.  pdl_print((uint8 *)&gparg.x.a_getpak,
  74.      GETPAK,
  75.      sizeof(gparg.x.a_getpak));
  76.  /*print the data packet*/
  77.  pdl_print((uint8 *)gparg.x.a_getpak.pak_data,
  78.             ATALK_root,
  79.             gparg.x.a_getpak.pak_size);
  80.  
  81.  /*if the buffer has characters in it, empty them*/
  82.  if(out_break!=NIL)        /*if buffere is not empty*/
  83.      out_break=out_pt;    /*print everything this time*/
  84.      flush_out();        /*print them*/
  85.  
  86.  return false;
  87. }
  88.  
  89.